import jsonp from '../../src/common/js/jsonp'
import {commonParams, options} from "./config";
import axios from 'axios';

// 获取推荐页面的轮播图的数据
export function getRecomment(callback){
	axios('/vkey/cgi-bin/musicu.fcg',{
		params:{
			"cgiKey": "GetHomePage",
			"_": "1578908583179",
			"data": {"comm":{"g_tk":5381,"uin":"","format":"json","inCharset":"utf-8","outCharset":"utf-8","notice":0,"platform":"h5","needNewCode":1},"MusicHallHomePage":{"module":"music.musicHall.MusicHallPlatform","method":"MobileWebHome","param":{"ShelfId":[101,102,161]}},"hotkey":{"module":"tencent_musicsoso_hotkey.HotkeyService","method":"GetHotkeyForQQMusicMobile","param":{"remoteplace":"txt.miniapp.wxada7aab80ba27074","searchid":"1559616839293"}}}
		}
	}).then(data=>{
		callback(data)
	}).catch(error=>{
		callback(error)
	})
}

// 获取热门歌单推荐列表的数据
export function getDiscList() {
   const url = '/api/getDiscList'  //调用自定义的接口

    const data = Object.assign({}, commonParams, {
        platform: 'yqq',
        hostUin: 0,
        sin: 0,
        ein: 29,
        sortId: 5,
        needNewCode: 0,
        categoryId: 10000000,
        rnd: Math.random(),
        format: 'json'    //使用的是axios,所以format使用的是json,不是jsonp
    })

    // return jsonp(url, data, options)
    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data) //es6新语法，返回一个以给定值解析后的Promise对象
    })
}

// 获取热门歌单详情的数据
export function getHotMusicList(disstid) {
    const url = '/api/hotmusicList'  //调用自定义的接口
 
     const data = Object.assign({}, {
        "type": 1,
        "json": 1,
        "utf8": 1,
        "onlysong": 0,
        "new_format": 1,
        "disstid": disstid,
       " g_tk": 5381,
        "loginUin": 1337312569,
        "hostUin": 0,
        "format": "json",
        "inCharset": "utf8",
        "outCharset": "utf-8",
        "notice": 0,
        "platform": "yqq.json",
        "needNewCode": 0   ,//使用的是axios,所以format使用的是json,不是jsonp
     })
 
     // return jsonp(url, data, options)
     return axios.get(url, {
         params: data
     }).then((res) => {
         return Promise.resolve(res.data) //es6新语法，返回一个以给定值解析后的Promise对象
     })
 }
